set hive.exec.dynamic.partition = true;
set hive.exec.dynamic.partition.mode = 'nonstrict';
set hive.exec.max.dynamic.partitions.pernode = 200;
set hive.exec.max.dynamic.partitions = 200;
insert overwrite table jms_dm.dm_start_center_violate_cnt_dt
select
date_time as  scan_time
,center_code
,max(center_name) as center_name
,agent_code
,max(agent_name)  as agent_name
,count(1)-sum(is_should_bagging) as not_should_bag_cnt --不应建包数
,count(if(violate_type is not null,1,null) ) as violate_cnt --违规建包数
,count(if(violate_type='重量违规' ,1,null)) as weight_violate_cnt
,count(if(violate_type='边长违规' ,1,null)) as side_violate_cnt
,count(if(violate_type='单流向数量违规' ,1,null)) as flow_violate_cnt
,date_time 
,dt
from jms_dm.dm_start_center_violate_detail_dt
where dt ='{{ execution_date | cst_ds }}' or dt=date_add('{{ execution_date | cst_ds }}',-4)
group by dt,date_time,center_code,agent_code
distribute by 1;
